Skip to content

perf(zkatdlog): optimize IPA prover using native gnark-crypto arithmetic - #2154

Open
SurbhiAgarwal1 wants to merge 2 commits into
LFDT-Panurus:mainfrom
SurbhiAgarwal1:perf/zkp-ipa-optimization
Open

perf(zkatdlog): optimize IPA prover using native gnark-crypto arithmetic#2154
SurbhiAgarwal1 wants to merge 2 commits into
LFDT-Panurus:mainfrom
SurbhiAgarwal1:perf/zkp-ipa-optimization

Conversation

@SurbhiAgarwal1

Copy link
Copy Markdown
Contributor

Description

This PR introduces native gnark-crypto field arithmetic for the Inner Product Argument (IPA) prover to eliminate the allocation overhead of the generic mathlib wrapper in tight reduction loops. Supersedes #1912.

As discussed in #1432 and the parent performance epic (#954), the core curve layer heavily relies on mathlib interface allocations, which becomes a bottleneck during Bulletproof/IPA proof generation.

Changes Made

  • Native IPA Execution: Created ipa_native.go containing nativeIPAReduce to execute round reductions natively.
  • Dynamic Curve Dispatch: Updated ipaProver.reduce to dynamically dispatch execution based on the underlying curve via math.DispatchCurve (BLS12-381 and BN254).
  • In-Place Generic Arithmetic: Converted vectors into gnark-crypto native array types (math.GnarkFr[T]) for in-place scalar computations.

Related Issues

Type of Change

  • Performance Improvement (optimizing code execution and memory allocations)

Testing Done

  • Unit tests passed (make unit-tests)
  • Verified against all bit-lengths and tampering test cases.

@SurbhiAgarwal1
SurbhiAgarwal1 force-pushed the perf/zkp-ipa-optimization branch from aca7240 to d4f768b Compare August 6, 2026 09:30
Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
@SurbhiAgarwal1
SurbhiAgarwal1 force-pushed the perf/zkp-ipa-optimization branch from d4f768b to 4b48652 Compare August 6, 2026 09:43
@SurbhiAgarwal1

Copy link
Copy Markdown
Contributor Author

Hi @adecaro and @AkramBitar ,

I have updated the PR branch (perf/zkp-ipa-optimization) to resolve the CI build and check failures:

  1. Fixed Module Import Paths: Updated imports in token/core/zkatdlog/nogh/v1/crypto/rp/bulletproof/ from legacy github.com/hyperledger-labs/fabric-token-sdk to github.com/LFDT-Panurus/panurus matching go.mod.
  2. Code Formatting: Applied gofmt -s -w across all modified files in bulletproof to resolve the make checks formatting failure.
  3. Verification:
    • All unit tests in token/core/zkatdlog/nogh/v1/crypto/rp/bulletproof pass locally (go test ./... PASS).
    • cgo-check builds (tokengen, artifactgen) compile with CGO_ENABLED=0.
    • DCO sign-off is included in the commit.

Could you please trigger/re-run the CI workflows and let me know if any further changes are needed? Thanks!

@AkramBitar

Copy link
Copy Markdown
Contributor

@SurbhiAgarwal1

Thanks a lot for submitting this PR!
I also want to apologize in advance if it takes me some time to review it. I'll get to it as soon as possible.

Regards,
Akram

@AkramBitar

Copy link
Copy Markdown
Contributor

@neetance

Could you please help to review this PR?

Thanks a lot,
Akram

@neetance

neetance commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, @SurbhiAgarwal1, the native-arithmetic port of the inner-product/MSM prep looks good and follows the existing GnarkFr[T] pattern correctly.
Can you also share the benchmark numbers for before and after the changes so that we can make the complete comparison and see the overall effects of this pr.
Thanks 🙏

@AkramBitar

Copy link
Copy Markdown
Contributor

Thanks for this, @SurbhiAgarwal1, the native-arithmetic port of the inner-product/MSM prep looks good and follows the existing GnarkFr[T] pattern correctly. Can you also share the benchmark numbers for before and after the changes so that we can make the complete comparison and see the overall effects of this pr. Thanks 🙏

@neetance

Thanks a lot for your support.

Regards,
Akram

@SurbhiAgarwal1

Copy link
Copy Markdown
Contributor Author

Hi @neetance and @AkramBitar,

Here are the benchmark numbers for the native gnark-crypto arithmetic path:

  • BN254 Native IPA Prover: 13.70 ms/op (803,996 B/op, 8,010 allocs/op)
  • BLS12-381 Native IPA Prover: 22.99 ms/op (775,943 B/op, 6,659 allocs/op)
  • Standard IPA Prover Baseline: 20.48 ms/op (772,089 B/op, 6,638 allocs/op)
  • End-to-End Bulletproof Prover: 44.35 ms/op (1,097,854 B/op, 10,220 allocs/op)

Please see the attached terminal benchmark output below for complete details. Thanks!
Screenshot 2026-08-11 021659

@adecaro adecaro added this to the Q3/26 milestone Aug 11, 2026
@AkramBitar

AkramBitar commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Hi @SurbhiAgarwal1,

Thanks a lot for running the benchmarks! I assume these are the results after the fix. It would be great if we could also have the benchmark numbers from before and after the changes, so we can make a complete comparison and see the overall impact of this PR, as @neetance mentioned above.

Thanks a million,
Akram

@AkramBitar

Copy link
Copy Markdown
Contributor

Hello @SurbhiAgarwal1

Any update on that PR?

Regards,
Akram

@SurbhiAgarwal1

Copy link
Copy Markdown
Contributor Author

Hi @AkramBitar, apologies for the delay. I’ve been busy with some other work and haven’t been able to get back to this yet. I’ll work on the before-and-after benchmark comparison and update the PR within the next 2–3 days. Thanks for your patience!

@AkramBitar

Copy link
Copy Markdown
Contributor

@SurbhiAgarwal1
Thanks a lot for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize ZKP Computation Using CPU SIMD and Specialized Instructions

4 participants